<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      var obj2 = {
        a: this,
        obj: {
          name: "111",
          aa: this,
          func1: () => {
            console.log(this);
          },
        },
      };
      var name = "333";
      var obj = {
        name: "222",
        clickBind: function () {
          var name = "111";
          let arrow = () => {
            console.log(this.name);
          };
          arrow();
        },
      };
      obj.clickBind(); //222
      // 箭头函数里面不绑定this 所以里面没有this 他会向上面寻找 找到this就为那个this
      // 第二个例子中clickBind不是箭头函数绑定this且this指向调用者所以里面的箭头函数也指向调用者
      console.log(obj2.obj.aa);
    </script>
  </body>
</html>
